import { baseUrl, billBaseUrl } from "@/utils/config.js"
const placeholderStyle = 'color:#ccc;font-size:28rpx;font-weight: bold;'
const displayStyle = 'display: flex;align-items: center;justify-content: center;'
const inputStyle = {
  fontSize: '28rpx',
  textAlign: 'right',
  fontWeight: 'bold',
}
const rightStyle = 'width: 44rpx;height: 70rpx;display: flex;justify-content: flex-end;align-items: center;'
const collectionModel = {
  title: '收款收据(通用)',
  type: 'collection',
  rules: {
    customerName: [{
      required: true,
      message: '请填写客户姓名',
      trigger: ['change', 'blur']
    }],
    actualAmount: [{
      required: true,
      message: '请填写收款金额',
      trigger: ['change', 'blur']
    }]
  },
  data: [[
    {
      key: 'copy',
      type: 'copy',
      placeholder: '粘贴信息，自动拆分客户名称、电话',
      style: 'min-height: 140rpx;',
    }
  ],
  [{
    type: 'title',
    label: '今收到'
  },
  {
    key: 'customerName',
    type: 'input',
    inputType: 'text',
    label: '客户名称',
    placeholder: '填写客户名称',
    customStyle: inputStyle,
    placeholderStyle: placeholderStyle,
    required: true,
    height: 70,
    clearable: false,
    borderBottom: true,
    right: {
      style: rightStyle,
      img: billBaseUrl + 'tiaozhuantongxunlu@3x.png',
      label: '',
      imageViewStyle: displayStyle + 'width: 32rpx;height:32rpx;flex-shrink: 0;',
      func: 'chooseMember'
    },
  },
  {
    key: 'customerPhone',
    type: 'input',
    inputType: 'number',
    label: '联系电话',
    placeholder: '请填写客户联系方式',
    customStyle: inputStyle,
    placeholderStyle: placeholderStyle,
    required: false,
    height: 70,
    clearable: false,
    borderBottom: false,
    right: null,
  }
  ], [
    {
      key: 'extend',
      subKey: 'collectionReason',
      type: 'textarea',
      inputType: 'normal-reason',
      label: '交来',
      required: true,
      placeholder: '举例：购买了4个苹果、6个橙子1个西瓜。',
      style: 'min-height: 202rpx;',
      func: 'editRemark'
    }
  ], [
    {
      key: 'timeInfo',
      type: 'time',
      label: '收款时间',
      list: [
        {
          key: 'day',
          img: baseUrl + 'riqi@3x.png',
          placeholder: '选择收款时间',
          func: 'handleClickDate',
          ref: {
            key: 'timeInfo',
            subKey: 'day',
            type: 'date',
            show: false,
            ref: 'day',
          }
        },
      ]
    },
    {
      key: 'actualAmount',
      type: 'input',
      inputType: 'digit',
      label: '收款金额',
      placeholder: '填写收款金额',
      customStyle: inputStyle,
      placeholderStyle: placeholderStyle,
      required: true,
      height: 70,
      clearable: false,
      borderBottom: true,
      right: null
    },
    {
      key: 'extend',
      subKey: 'payType',
      type: 'select',
      label: '支付方式',
      labels: ['微信', '支付宝', '转账', '现金', '其他'],
      func: 'selectType',
      borderBottom: true,
    },
    {
      key: 'remark',
      type: 'textarea',
      label: '备注',
      placeholder: '请填写备注信息',
      inputType: 'maintain-remark',
      func: 'editRemark',
	  right: {
	    label: '选模板',
	    func: 'chooseRemark'
	  }
    }
  ], [
    {
      key: 'extend',
      subKey: 'customerSignSwitch',
      type: 'switch',
      label: '是否需要客户签字'
    }
  ],
  [
    {
      key: 'extend',
      type: 'seal',
    }
  ]],
  sealInfos: [
    {
      label: "水印",
      selectText: '选择电子水印',
      url: '',
      selected: true,
      value: '1',
      code: 'ELECTRON',
      width: 202,
    },
    {
      label: "公章",
      selectText: '选择公章',
      url: '',
      selected: false,
      value: '2',
      code: 'OFFICIAL',
      width: 202,
    },
    {
      label: "不使用",
      url: '',
      selected: false,
      value: '3',
      code: '',
      width: 202,
    }
  ],
  initFormFunc: (form) => { },
  changeFormFunc: (val) => {
    let form = JSON.parse(JSON.stringify(val))
    form.receivableAmount = form.actualAmount
    form.extend.collectionTime = form.timeInfo.day + ' ' + form.timeInfo.time
    return form
  },
  setFormFunc: (form)=> {
  }
}

export default collectionModel